%==========================================================================
%=  This file is part of the Sound Restoration Project
%=  (c) Copyright Industrial Mathematics Institute
%=                University of South Carolina, Department of Mathematics
%=  ALL RIGHTS RESERVED
%=
%=  Author: Borislav Karaivanov
%==========================================================================

%==========================================================================
% List of the files on which this procedure depends:
%
% writeToLogFile.m
%
%==========================================================================

%==========================================================================
% The function "setLogWritingFunctHandle" sets a function handle which
% allows to write a string to a specified log text file if requested, or do
% nothing otherwise.
% INPUT: "logFileName" is the name (including a full directory path) of the
% log text file where strings are to be written.
% "isLogKeepingOn" is a boolean parameter specifying whether to write to
% the specified file or not to write at all.
% OUTPUT: "functHandle" returns a function handle with the described
% functionality.
%==========================================================================
function functHandle = setLogWritingFunctHandle(logFileName, isLogKeepingOn)

% If log keeping is requested then write the given string to the specified
% log file. Otherwise, simply return the log file name.
if (isLogKeepingOn == true)
    functHandle = @(x) writeToLogFile(logFileName, x);
else
    functHandle = @(x) logFileName;
end

return;
% end of the function "setLogWritingFunctHandle"
